<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>持明法洲登录页面</title>
    <script src="${pageContext.request.contextPath}/js/jquery-1.10.1.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css" media="all">
    <link rel="stylesheet"  href="${pageContext.request.contextPath}/css/plugins/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <script src="${pageContext.request.contextPath}/layui/layui.js" type="text/javascript"></script>

</head>

<body class="layui-layout-login">
<div class="login-bg">
    <div class="cover"></div>
</div>
<div class="login-content" >
    <h1 class="login-box-title"><i class="fa fa-fw fa-user"></i>登录</h1>
    <form class="layui-form" id="login" method="post">

        <div class="layui-form-item">
            <label class="layui-icon layui-icon-username" for="username"></label>
            <input class="layui-input" type="text" name="username" id="username" placeholder="用户名">
        </div>

        <div class="layui-form-item">
            <label class="layui-icon layui-icon-password" for="password"></label>
            <input class="layui-input" type="password" name="password" id="password" placeholder="密码">
        </div>

        <div class="layui-form-item captcha-item">
            <label class="layui-icon layui-icon-vercode"></label>
            <input class="layui-input" type="text" name="code" autocomplete="off" placeholder="验证码">
            <img id="imgVcode" src="${pageContext.request.contextPath}/code/selectCode">
        </div>

        <button type="button" class="layui-btn layui-btn-fluid ajax-login" id="submit" lay-filter="*"><i class="fa fa-sign-in fa-lg fa-fw"></i> 登录</button>
    </form>
</div>
<script>

    layui.use('form', function() {
        var form = layui.form;

        $("#submit").click(function () {
        var s = $("#login").serialize();
        $.ajax({
        url:'${pageContext.request.contextPath}/admin/login',
        data:s,
        dataType:"json",
        success:function(result){
        if(result.flag){
        location.href="${pageContext.request.contextPath}/main.jsp";
        }else {
        layer.msg(result.msg);
        }
        }
        })
        })
        <%--form.on('submit(*)',function(){--%>
            <%--console.log("11111");--%>
            <%--&lt;%&ndash;var s = $("#login").serialize();&ndash;%&gt;--%>
            <%--&lt;%&ndash;$.ajax({&ndash;%&gt;--%>
            <%--&lt;%&ndash;url:'${pageContext.request.contextPath}/user/login',&ndash;%&gt;--%>
            <%--&lt;%&ndash;data:s,&ndash;%&gt;--%>
            <%--&lt;%&ndash;dataType:"json",&ndash;%&gt;--%>
            <%--&lt;%&ndash;success:function(result){&ndash;%&gt;--%>
            <%--&lt;%&ndash;if(result.flag){&ndash;%&gt;--%>
            <%--&lt;%&ndash;location.href="${pageContext.request.contextPath}/index.jsp";&ndash;%&gt;--%>
            <%--&lt;%&ndash;}else {&ndash;%&gt;--%>
            <%--&lt;%&ndash;layer.msg(result.msg);&ndash;%&gt;--%>
            <%--&lt;%&ndash;}&ndash;%&gt;--%>
            <%--&lt;%&ndash;}&ndash;%&gt;--%>
            <%--&lt;%&ndash;})&ndash;%&gt;--%>
            <%--&lt;%&ndash;return false;&ndash;%&gt;--%>
        <%--})--%>
    })
</script>
</body>
</html>
